<template>
	<view class="main">
		<view class="carInfo">
			<view class="carCommon carNumber">
				<view>车辆号码</view>
				<view>
					<input type="text" placeholder="填写车牌号" placeholder-class="srCarnum" @input="carNum">
				</view>
			</view>
			<view class="carCommon carBrand">
				<view>品牌车系</view>
				<view class="uni-list-cell-db">
					<picker @change="bindPickerChange" :value="index" :range="array" range-key="name">
						<view class="choose" :hidden="isSelectCarBrand">选择品牌车系 <image src="../../static/my/rightarrow.png" mode=""></image></view>
						<view class="uni-input" :hidden="!isSelectCarBrand">{{array[index].name}}</view>
					</picker>
				</view>
			</view>
		</view>
		<view class="saveCarInfo" @click="save">保存</view>
	</view>
</template>

<script>
	export default {
		data() {
			return {
				title: 'picker',
				array: [],
				index: 0,
				isSelectCarBrand:false
			}
		},
		onLoad() {
			this.getBrandCarName();
		},
		onShow() {
			
		},
		methods: {
			//获取品牌车辆名称
			getBrandCarName() {
				this.$get('auto_pinpai.ashx',{},(res)=>{
					this.array = res.data;
					console.log(this.array)
				})
			},
			bindPickerChange: function(e) {
				if(this.isSelectCarBrand == false) {
					this.isSelectCarBrand = true
				}
				console.log('picker发送选择改变，携带值为', e.target.value)
				this.index = e.target.value
			},
			//输入车牌号
			carNum(e){
				console.log(e.detail);
				this.carnumber = e.detail;
			},
			//保存车辆信息
			save(){
				if(this.carnumber == '') {
					uni.showToast({
						title:'车牌号不能为空!',
						icon:'none'
					})
					return
				} 
				this.$post('customer_auto.ashx',{
					id:uni.getStorageSync('userId'),
					},(res)=>{
					console.log(res)
				})
			}
		}
	}
</script>

<style>
	page {
		font-family: '苹方';
	}
	.carInfo .carCommon {
		width: 750rpx;
		height: 110rpx;
		line-height: 110rpx;
		display: flex;
		justify-content: space-between;
		align-items: center;
		background: #fff;
		padding: 0 24rpx;
		box-sizing: border-box;
		border-bottom: 1rpx solid #eeeeee;
	} 
	.carNumber input {
		text-align: right;
	}
	.srCarnum {
		font-family: '苹方';
		font-size: 30rpx;
		color: #999;
	} 
	.carBrand image {
		width: 23rpx;
		height: 38rpx;
		vertical-align: sub;
		margin-left: 12rpx;
	}
	.choose {
		font-size: 30rpx;
		color: #999;
	}
	.uni-list-cell-db {
		flex: 0.4;
	}
	.uni-input {
		text-align: center;
	}
	.saveCarInfo {
		width: 702rpx;
		height: 84rpx;
		line-height: 84rpx;
		background: #008afd;
		text-align: center;
		color: #fff;
		border-radius: 10rpx;
		position: fixed;
		bottom: 218rpx;
		left: 50%;
		margin-left: -351rpx;
	}
</style>